40
Classes and Objects in C++
 Instances of classes are called objects. Recall the circle and point example. There a class Point has been developed. In C++ this would look like this:
 class Point {
    int _x, _y;       // point coordinates
  public:             // begin interface section
    void setX(const int val);
    void setY(const int val);
    int getX() { return _x; }
    int getY() { return _y; }
  };
  Point apoint;
This declares a class Point and defines an object apoint. You can think of a class definition as a structure definition with functions (or ``methods''). Additionally, you
can specify the access rights in more detail. For example, _x and _y are private, because elements of classes are private as default. Consequently, we explicitly
must ``switch'' the access rights to declare the following to be public. We do that by using the keyword public followed by a colon: Every element following this
keyword are now accessible from outside of the class.